package com.sun.springbootfiledownload.dto;

import com.sun.springbootfiledownload.enums.UploadTaskStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import java.time.Instant;

/**
 * @version 1.0
 * @Package: com.sun.springbootfiledownload.dto
 * @ClassName: UploadTask
 * @Author: sgq
 * @Date: 2025/4/11 14:14
 * @Description: TODD
 */
@Data
public class UploadTask {
    private String taskId;           // 任务唯一ID
    private String fileName;         // 原始文件名
    private long fileSize;           // 文件大小(bytes)
    private String targetFolder;     // OSS目标目录
    private UploadTaskStatus status; // 当前状态
    private int progress;            // 进度百分比(0-100)
    private String ossUrl;           // 上传成功后的URL
    private String errorMsg;         // 失败信息
    private Instant createTime;      // 任务创建时间
    private byte[] fileBytes; // 添加文件字节数组字段

    // 构造函数
    public UploadTask(String taskId, String fileName, long fileSize, String targetFolder, UploadTaskStatus status, int progress, String ossUrl, String errorMsg, Instant createdAt, byte[] fileBytes) {
        this.taskId = taskId;
        this.fileName = fileName;
        this.fileSize = fileSize;
        this.targetFolder = targetFolder;
        this.status = status;
        this.progress = progress;
        this.ossUrl = ossUrl;
        this.errorMsg = errorMsg;
        this.createTime = createdAt;
        this.fileBytes = fileBytes;
    }

    // Getter 和 Setter 方法
    public byte[] getFileBytes() {
        return fileBytes;
    }

    public void setFileBytes(byte[] fileBytes) {
        this.fileBytes = fileBytes;
    }
}